package com.example.date;

import java.time.LocalDate;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * @author hej
 * @date 2023/4/11 20:27
 */
public class DateTest4 {
    public static void main(String[] args) {
        LocalDate startDate = LocalDate.now();
        startDate = startDate.plusDays(19);
        /**
         * 那个YMD要写个参数类型：WO_YMD；时间来源是MES工单关联的SAP工单的计划开始时间；
         * Y取年份的最后一位；M取月份，当超过1位时，有个对照转换：10->A;11->B;12->C;
         * D取天数，按照32位进行取值（32进制是在36进制基础上去除：I、O、Q、U）：比如超过9,10=A,11=B。。。
         */
        List<String> dayList = Arrays.asList("0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","V","W","X","Y","Z");
        long month = startDate.getMonth().getValue();
        String y = startDate.getYear() % 10 + "";
        String m = month == 10 ? "A" : month == 11 ? "B" : month == 12 ? "C" : month + "";
        String d = dayList.get(startDate.getDayOfMonth());
        System.out.println(startDate);
        System.out.println(y + m + d);

        String replace = "{MaterialNo}|{MaterialRev}|{WO_YMD}|[SEQ]";
        List<String> rules = Arrays.asList(replace.split("\\|"));
        for(String param : rules){
            System.out.println(param);
            //匹配是否已  { 字符开始   } 字符结束
            Pattern pp = Pattern.compile("\\{.*?}");
            Matcher matcherpp = pp.matcher(param);
            System.out.println(matcherpp.matches());
            //去除 {， }
            param = param.replaceAll("[\\{\\}]", "");
            System.out.println(param);
        }
    }
}
